﻿
@{
    ViewBag.Title = "商品分类";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@model IList<Mate.Dto.Good.GoodCategoryTreeModel>
@section styles{

    <link href="~/bootstrap/plugins/treegrid/jquery.treegrid.css" rel="stylesheet" />
}

@section scripts{

    <script src="~/bootstrap/plugins/treegrid/jquery.treegrid.js"></script>
    <script src="~/bootstrap/plugins/treegrid/jquery.treegrid.bootstrap3.js"></script>

    <script type="text/javascript">
        $(function () {
            $('.tree').treegrid();


        });

        function Remove(id){
            layer.confirm('确定要删除？', {
                btn: ['删除', '取消'] //按钮
            }, function () {
                $.post("@Url.Action("Remove")", { id: id }, function (result) {
                    if (result.resultCode == 1000) {
                        layer.msg(result.message, {
                            icon: 1,
                            time: 1500
                        }, function () {
                            location.href = location.href;
                        });
                    } else {
                        layer.open({
                            content: result.message
                        });
                    }

                });
            });
        }
    </script>
}

<ul class="page-breadcrumb breadcrumb">
    <li>
        <a href="@Url.Action("Index", "GoodCategory")">
            商品分类
        </a>
    </li>
</ul>

<div class="row">

    <div class="col-md-12">
        <div class="portlet-body">
            <div class="row">
                <div class="form-group">
                    <div class="col-md-8">
                        <div class="btn-group btn-group-solid">
                            <a href="@Url.Action("Create")" class="btn green" role="button" title="新增"><i class="fa fa-plus"></i> 新增</a>
                        </div>
                    </div>
                </div>
            </div><br />
            <table class="tree table table-hover table-bordered table-condensed">
                <tr>
                    <th>分类名称</th>
                    <th>状态</th>
                    <th>图片</th>
                    <th>操作</th>
                </tr>
                @if (Model != null)
                {
                    foreach (var item1 in Model)
                    {
                <tr class="treegrid-@(item1.id)">
                    <td>@(item1.name)</td>
                    <td><span style='color:@(item1.is_open==1?"green":"red");'>@(item1.is_open == 1 ? "启用" : "禁用")</span></td>
                    <td><img style="max-height:30px" src="@item1.img" /></td>
                    <td>
                        <a href="@Url.Action("Edit")/@(item1.id)" class="btn btn-xs green"><i class="fa fa-edit"></i> 修改 </a>
                        <a href="javascript:void(0);" onclick="Remove('@item1.id');" class="btn btn-xs yellow" role="button" title="删除"><i class="fa fa-times"></i> 删除</a>
                    </td>
                </tr>
                        if (item1.children.Any())
                        {
                            foreach (var item2 in item1.children)
                            {
                <tr class="treegrid-@(item2.id) treegrid-parent-@(item1.id)">
                    <td>@(item2.name)</td>
                    <td><span style='color:@(item2.is_open==1?"green":"red");'>@(item2.is_open == 1 ? "启用" : "禁用")</span></td>
                    <td><img style="max-height:30px" src="@item2.img" /></td>
                    <td>
                        <a href="@Url.Action("Edit")/@(item2.id)" class="btn btn-xs green"><i class="fa fa-edit"></i> 修改 </a>
                        <a href="javascript:void(0);" onclick="Remove('@item2.id');" class="btn btn-xs yellow" role="button" title="删除"><i class="fa fa-times"></i> 删除</a>
                    </td>
                </tr>
                                if (item2.children.Any())
                                {
                                    foreach (var item3 in item2.children)
                                    {
                <tr class="treegrid-@(item3.id) treegrid-parent-@(item2.id)">
                    <td>@(item3.name)</td>
                    <td><span style='color:@(item3.is_open==1?"green":"red");'>@(item3.is_open == 1 ? "启用" : "禁用")</span></td>
                    <td><img style="max-height:30px" src="@item3.img" /></td>
                    <td>
                        <a href="@Url.Action("Edit")/@(item3.id)" class="btn btn-xs green"><i class="fa fa-edit"></i> 修改 </a>
                        <a href="javascript:void(0);" onclick="Remove('@item3.id');" class="btn btn-xs yellow" role="button" title="删除"><i class="fa fa-times"></i> 删除</a>
                    </td>
                </tr>
                                    }
                                }
                            }
                        }
                    }

                }
            </table>

        </div>
    </div>
</div>

